//
//  UIBarButtonItem + Extension.swift
//  zhibo
//
//  Created by Echo on 16/9/21.
//  Copyright © 2016年 Echo. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    convenience init(imageName : String, highImageName : String = "", size : CGSize = CGSizeZero){
        
        let btn = UIButton()
        
        btn.setImage(UIImage(named : imageName), forState: .Normal)
        if highImageName != "" {
            btn.setImage(UIImage(named: highImageName), forState: .Highlighted)
        }
        
        if size == CGSizeZero {
            btn.sizeToFit()
        }else {
            btn.frame = CGRect(origin: CGPointZero, size: size)
        }
        
        self.init(customView : btn)
    }
    
}
